package guis;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;

public abstract class AbstractGUI {

    protected Composite tshell;
    protected Composite centerShell;
    protected Composite leftPanel;

    public Composite createLeftPanel() {
	// Left Panel
	Composite leftPanel = new Composite(tshell, SWT.NONE);
	FormData fd_leftPanelComposite = new FormData();
	fd_leftPanelComposite.right = new FormAttachment(0, 150);
	fd_leftPanelComposite.top = new FormAttachment(0, 10);
	fd_leftPanelComposite.left = new FormAttachment(0, 10);
	fd_leftPanelComposite.bottom = new FormAttachment(100, -10);
	leftPanel.setLayoutData(fd_leftPanelComposite);
	this.leftPanel = leftPanel;
	return leftPanel;
    }

    public Composite createMainPanel() {
	// Main Panel
	Composite centerShell = new Composite(tshell, SWT.NONE);
	centerShell.setLayout(new FillLayout(SWT.HORIZONTAL));
	FormData fd_mainComposite = new FormData();
	fd_mainComposite.bottom = new FormAttachment(leftPanel, 0, SWT.BOTTOM);
	fd_mainComposite.right = new FormAttachment(0, SWT.RIGHT);
	fd_mainComposite.top = new FormAttachment(0, 6);
	fd_mainComposite.left = new FormAttachment(leftPanel, 6);
	centerShell.setLayoutData(fd_mainComposite);

	centerShell.setLayout(new FillLayout(SWT.VERTICAL));

	this.centerShell = centerShell;
	return centerShell;
    }

    public abstract void disposeControls();

    public void close() {

	disposeControls();

	for (Control t : tshell.getChildren()) {
	    t.dispose();
	}
    }

}
